package com.xjrsoft.module.ureport.controller;


import com.xjrsoft.common.result.Response;
import com.xjrsoft.module.ureport.dto.GetReleasePageListDto;
import com.xjrsoft.module.ureport.dto.ReportReleaseDto;
import com.xjrsoft.module.ureport.service.IXjrReportReleaseService;
import io.swagger.annotations.ApiOperation;
import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 报表菜单关联关系表 前端控制器
 * </p>
 *
 * @author zwq
 * @since 2021-04-14
 */
@RestController
@RequestMapping("/reports-release")
public class XjrReportReleaseController {


    @Autowired
    private IXjrReportReleaseService iXjrReportReleaseService;
    
    @GetMapping
    @ApiOperation("获取报表发布列表 分页")
    public Response getReportRelease(GetReleasePageListDto dto) {
        return Response.ok(iXjrReportReleaseService.getPageList(dto));
    }

    @PostMapping
    @ApiOperation("新增报表文件")
    public Response saveReportRelease(@RequestBody ReportReleaseDto dto) throws Exception {
        return Response.status(iXjrReportReleaseService.saveReportRelease(dto));
    }

    @PutMapping("/{id}")
    @ApiOperation("修改报表文件")
    public Response updateReportRelease(@PathVariable String id, @RequestBody ReportReleaseDto dto) throws Exception {
        return Response.status(iXjrReportReleaseService.updateReportRelease(id, dto));
    }

    @SneakyThrows
    @DeleteMapping("/{ids}")
    @ApiOperation("删除报表文件")
    public Response deleteReportRelease(@PathVariable String ids) {
        return Response.status(iXjrReportReleaseService.deleteReportRelease(ids));
    }

}
